
package se.sll.service.catalogue.gui.api.resource;

import java.util.List;
import javax.validation.constraints.NotNull;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import se.sll.service.catalogue.gui.api.model.IdmapList;
import se.sll.service.catalogue.gui.api.model.ProductsByUnitList;
import se.sll.service.catalogue.gui.api.model.Unit;
import se.sll.service.catalogue.gui.api.model.UnitNameList;


/**
 * Aggredated service for fetching information from any of the underlying base information services
 * 
 */
@Path("aggregated")
public interface AggregatedService {


    /**
     * Lists all the capacity information for the provided list of unit id:s
     * 
     * @param entity
     *      e.g. {
     *       "units" :
     *         [
     *           {"unitId": "SE2321000016-4ZRK"},
     *           {"unitId": "SE2321000016-G82R"}
     *         ]
     *     }
     *     
     */
    @POST
    @Path("capacity/byunitids")
    @Consumes("application/json")
    @Produces({
        "application/json"
    })
    AggregatedService.PostAggregatedCapacityByunitidsResponse postAggregatedCapacityByunitids(UnitNameList entity)
        throws Exception
    ;

    /**
     * TODO - Ta bort!
     * 
     */
    @GET
    @Path("units")
    @Produces({
        "application/json"
    })
    AggregatedService.GetAggregatedUnitsResponse getAggregatedUnits()
        throws Exception
    ;

    /**
     * Reads the entire current Id map
     * 
     */
    @GET
    @Path("idmap")
    @Produces({
        "application/json"
    })
    AggregatedService.GetAggregatedIdmapResponse getAggregatedIdmap()
        throws Exception
    ;

    /**
     * Lists all capacity information for a specific care unit HSA Id.
     * 
     * @param hsaID
     *     
     */
    @GET
    @Path("capacity/{hsaID}")
    @Produces({
        "application/json"
    })
    AggregatedService.GetAggregatedCapacityByHsaIDResponse getAggregatedCapacityByHsaID(
        @PathParam("hsaID")
        @NotNull
        String hsaID)
        throws Exception
    ;

    /**
     * Some sort of test service that just throws an exception. Unknown if it is currently in use.
     * 
     */
    @GET
    @Path("test")
    AggregatedService.GetAggregatedTestResponse getAggregatedTest()
        throws Exception
    ;

    /**
     * Reads information for a specific Care Unit HSA Id
     * 
     * @param hsaId
     *     
     */
    @GET
    @Path("unit/{hsaId}")
    @Produces({
        "application/json"
    })
    AggregatedService.GetAggregatedUnitByHsaIdResponse getAggregatedUnitByHsaId(
        @PathParam("hsaId")
        String hsaId)
        throws Exception
    ;

    public class GetAggregatedCapacityByHsaIDResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private GetAggregatedCapacityByHsaIDResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested capacity information was found and is returned in the body. e.g. [
         *   {
         *     "hsaID": "SE2321000016-3TNL",
         *     "name": "Namn",
         *     "products": [
         *       {
         *         "id": "SE2321000016-1HF3",
         *         "name": "40",
         *         "capacity": [
         *           {
         *             "codeSystem": "oid.sll.vantetider",
         *             "code": "2",
         *             "displayName": "Namnet",
         *             "value": "4",
         *             "validTo": 1425410281000
         *           },
         *           {
         *             "codeSystem": "oid.sll.vantetider",
         *             "code": "2",
         *             "displayName": "Namnet",
         *             "value": "4",
         *             "validTo": 1425410281000
         *           }
         *         ]
         *       }
         *     ]
         *   }
         * ]
         * 
         * 
         * @param entity
         *     [
         *       {
         *         "hsaID": "SE2321000016-3TNL",
         *         "name": "Namn",
         *         "products": [
         *           {
         *             "id": "SE2321000016-1HF3",
         *             "name": "40",
         *             "capacity": [
         *               {
         *                 "codeSystem": "oid.sll.vantetider",
         *                 "code": "2",
         *                 "displayName": "Namnet",
         *                 "value": "4",
         *                 "validTo": 1425410281000
         *               },
         *               {
         *                 "codeSystem": "oid.sll.vantetider",
         *                 "code": "2",
         *                 "displayName": "Namnet",
         *                 "value": "4",
         *                 "validTo": 1425410281000
         *               }
         *             ]
         *           }
         *         ]
         *       }
         *     ]
         *     
         */
        public static AggregatedService.GetAggregatedCapacityByHsaIDResponse jsonOK(List<ProductsByUnitList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new AggregatedService.GetAggregatedCapacityByHsaIDResponse(responseBuilder.build());
        }

    }

    public class GetAggregatedIdmapResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private GetAggregatedIdmapResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested Id map was found and is returned in the body. e.g. [
         *   {
         *     "hsaId": "SE2321000016-4ZRK",
         *     "ekId": "213F3343342",
         *     "hsaRelativeDistinguishedName": "",
         *     "vmId": "34234",
         *     "vmCareGiverPartId": "SE2321000016-4Y9X",
         *     "vmCareGiverName": "SLSO",
         *     "vmCareGiverPartName": "SL",
         *     "kombika": "2351223L01",
         *     "sklId": "VG14141121",
         *     "allowExport": false,
         *     "allowImport": false
         *   }
         * ]
         * 
         * 
         * @param entity
         *     [
         *       {
         *         "hsaId": "SE2321000016-4ZRK",
         *         "ekId": "213F3343342",
         *         "hsaRelativeDistinguishedName": "",
         *         "vmId": "34234",
         *         "vmCareGiverPartId": "SE2321000016-4Y9X",
         *         "vmCareGiverName": "SLSO",
         *         "vmCareGiverPartName": "SL",
         *         "kombika": "2351223L01",
         *         "sklId": "VG14141121",
         *         "allowExport": false,
         *         "allowImport": false
         *       }
         *     ]
         *     
         */
        public static AggregatedService.GetAggregatedIdmapResponse jsonOK(List<IdmapList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new AggregatedService.GetAggregatedIdmapResponse(responseBuilder.build());
        }

    }

    public class GetAggregatedTestResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private GetAggregatedTestResponse(Response delegate) {
            super(delegate);
        }

    }

    public class GetAggregatedUnitByHsaIdResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private GetAggregatedUnitByHsaIdResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested unit information was found and is returned in the body. e.g. [
         *   {
         *     "creationTime": 1393305699000,
         *     "productReferences": [
         *       {
         *         "capacities": [],
         *         "comment": null,
         *         "contractedPrice": null,
         *         "contractedProduct": false,
         *         "product": {
         *             "codes": [],
         *             "creationTime": null,
         *             "description": null,
         *             "displayName": null,
         *             "name": "5",
         *             "status": null,
         *             "updateTime": null,
         *             "updatedByHsaid": null
         *         }
         *       }
         *     ],
         *     "regionalUnitId": "SE2321000016-4ZRK",
         *     "relativeDistinguishedName": null,
         *     "unitId": "SE2321000016-4ZRK",
         *     "updateTime": 1425911569000
         *   }
         * ]
         * 
         * 
         * @param entity
         *     [
         *       {
         *         "creationTime": 1393305699000,
         *         "productReferences": [
         *           {
         *             "capacities": [],
         *             "comment": null,
         *             "contractedPrice": null,
         *             "contractedProduct": false,
         *             "product": {
         *                 "codes": [],
         *                 "creationTime": null,
         *                 "description": null,
         *                 "displayName": null,
         *                 "name": "5",
         *                 "status": null,
         *                 "updateTime": null,
         *                 "updatedByHsaid": null
         *             }
         *           }
         *         ],
         *         "regionalUnitId": "SE2321000016-4ZRK",
         *         "relativeDistinguishedName": null,
         *         "unitId": "SE2321000016-4ZRK",
         *         "updateTime": 1425911569000
         *       }
         *     ]
         *     
         */
        public static AggregatedService.GetAggregatedUnitByHsaIdResponse jsonOK(List<Unit> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new AggregatedService.GetAggregatedUnitByHsaIdResponse(responseBuilder.build());
        }

    }

    public class GetAggregatedUnitsResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private GetAggregatedUnitsResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested unit information was found and is returned in the body. e.g. [
         *   {
         *     "creationTime": 1393305699000,
         *     "productReferences": [
         *       {
         *         "capacities": [],
         *         "comment": null,
         *         "contractedPrice": null,
         *         "contractedProduct": false,
         *         "product": {
         *             "codes": [],
         *             "creationTime": null,
         *             "description": null,
         *             "displayName": null,
         *             "name": "5",
         *             "status": null,
         *             "updateTime": null,
         *             "updatedByHsaid": null
         *         }
         *       }
         *     ],
         *     "regionalUnitId": "SE2321000016-4ZRK",
         *     "relativeDistinguishedName": null,
         *     "unitId": "SE2321000016-4ZRK",
         *     "updateTime": 1425911569000
         *   }
         * ]
         * 
         * 
         * @param entity
         *     [
         *       {
         *         "creationTime": 1393305699000,
         *         "productReferences": [
         *           {
         *             "capacities": [],
         *             "comment": null,
         *             "contractedPrice": null,
         *             "contractedProduct": false,
         *             "product": {
         *                 "codes": [],
         *                 "creationTime": null,
         *                 "description": null,
         *                 "displayName": null,
         *                 "name": "5",
         *                 "status": null,
         *                 "updateTime": null,
         *                 "updatedByHsaid": null
         *             }
         *           }
         *         ],
         *         "regionalUnitId": "SE2321000016-4ZRK",
         *         "relativeDistinguishedName": null,
         *         "unitId": "SE2321000016-4ZRK",
         *         "updateTime": 1425911569000
         *       }
         *     ]
         *     
         */
        public static AggregatedService.GetAggregatedUnitsResponse jsonOK(List<Unit> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new AggregatedService.GetAggregatedUnitsResponse(responseBuilder.build());
        }

    }

    public class PostAggregatedCapacityByunitidsResponse
        extends se.sll.service.catalogue.gui.api.support.ResponseWrapper
    {


        private PostAggregatedCapacityByunitidsResponse(Response delegate) {
            super(delegate);
        }

        /**
         * The requested capacity information was found and is returned in the body. e.g. [
         *   {
         *     "hsaID": "SE2321000016-3TNL",
         *     "name": "Namn",
         *     "products": [
         *       {
         *         "id": "SE2321000016-1HF3",
         *         "name": "40",
         *         "capacity": [
         *           {
         *             "codeSystem": "oid.sll.vantetider",
         *             "code": "2",
         *             "displayName": "Namnet",
         *             "value": "4",
         *             "validTo": 1425410281000
         *           },
         *           {
         *             "codeSystem": "oid.sll.vantetider",
         *             "code": "2",
         *             "displayName": "Namnet",
         *             "value": "4",
         *             "validTo": 1425410281000
         *           }
         *         ]
         *       }
         *     ]
         *   }
         * ]
         * 
         * 
         * @param entity
         *     [
         *       {
         *         "hsaID": "SE2321000016-3TNL",
         *         "name": "Namn",
         *         "products": [
         *           {
         *             "id": "SE2321000016-1HF3",
         *             "name": "40",
         *             "capacity": [
         *               {
         *                 "codeSystem": "oid.sll.vantetider",
         *                 "code": "2",
         *                 "displayName": "Namnet",
         *                 "value": "4",
         *                 "validTo": 1425410281000
         *               },
         *               {
         *                 "codeSystem": "oid.sll.vantetider",
         *                 "code": "2",
         *                 "displayName": "Namnet",
         *                 "value": "4",
         *                 "validTo": 1425410281000
         *               }
         *             ]
         *           }
         *         ]
         *       }
         *     ]
         *     
         */
        public static AggregatedService.PostAggregatedCapacityByunitidsResponse jsonOK(List<ProductsByUnitList> entity) {
            Response.ResponseBuilder responseBuilder = Response.status(200).header("Content-Type", "application/json");
            responseBuilder.entity(entity);
            return new AggregatedService.PostAggregatedCapacityByunitidsResponse(responseBuilder.build());
        }

    }

}
